package com.ftg.learn.rbac.mapper;

import com.ftg.learn.rbac.entity.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ftg.learn.rbac.vo.PermissionVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Guobt
 * @since 2022-02-09
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    /**
     * 查询当前用户的权限
     *
     * @param uid
     * @return
     */
    @Select("select d.* from sys_user a\n" +
            "left join sys_user_role b on a.uid = b.uid\n" +
            "left join sys_role_permission c on b.rid = c.rid\n" +
            "left join sys_permission d on c.pid = d.pid " +
            "where a.uid = #{param1}")
    List<PermissionVo> showPermissionForUserId(String uid);



}
